package com.ruoyi.web.controller.media;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.media.service.IMediaDashboardService;

/**
 * 广电用户仪表盘Controller
 * 
 * @author ruoyi
 */
@Controller
@RequestMapping("/media/dashboard")
public class MediaDashboardController extends BaseController
{
    @Autowired
    private IMediaDashboardService mediaDashboardService;

    /**
     * 获取仪表盘所有数据
     */
    @GetMapping("/getDashboardData")
    @ResponseBody
    public AjaxResult getDashboardData()
    {
        Map<String, Object> dashboardData = mediaDashboardService.getDashboardData();
        return AjaxResult.success(dashboardData);
    }

    /**
     * 获取基础指标统计
     */
    @GetMapping("/getBaseMetrics")
    @ResponseBody
    public AjaxResult getBaseMetrics()
    {
        Map<String, Object> metrics = mediaDashboardService.getBaseMetrics();
        return AjaxResult.success(metrics);
    }

    /**
     * 获取业务品牌分布
     */
    @GetMapping("/getBusinessBrandDistribution")
    @ResponseBody
    public AjaxResult getBusinessBrandDistribution()
    {
        List<Map<String, Object>> distribution = mediaDashboardService.getBusinessBrandDistribution();
        return AjaxResult.success(distribution);
    }

    /**
     * 获取用户价值等级分布
     */
    @GetMapping("/getUserValueLevelDistribution")
    @ResponseBody
    public AjaxResult getUserValueLevelDistribution()
    {
        List<Map<String, Object>> distribution = mediaDashboardService.getUserValueLevelDistribution();
        return AjaxResult.success(distribution);
    }

    /**
     * 获取电视消费水平分布
     */
    @GetMapping("/getTvConsumeLevelDistribution")
    @ResponseBody
    public AjaxResult getTvConsumeLevelDistribution()
    {
        List<Map<String, Object>> distribution = mediaDashboardService.getTvConsumeLevelDistribution();
        return AjaxResult.success(distribution);
    }

    /**
     * 获取宽带消费水平分布
     */
    @GetMapping("/getBroadbandConsumeLevelDistribution")
    @ResponseBody
    public AjaxResult getBroadbandConsumeLevelDistribution()
    {
        List<Map<String, Object>> distribution = mediaDashboardService.getBroadbandConsumeLevelDistribution();
        return AjaxResult.success(distribution);
    }

    /**
     * 获取用户增长趋势
     */
    @GetMapping("/getUserGrowthTrend")
    @ResponseBody
    public AjaxResult getUserGrowthTrend(String startTime, String endTime)
    {
        List<Map<String, Object>> trend = mediaDashboardService.getUserGrowthTrend(startTime, endTime);
        return AjaxResult.success(trend);
    }
}